//
//  def_comparison_expression.h
//  compilation
//
//  Created by Kevin Le perf on 17/01/12.
//  Copyright (c) 2012 e2co technologie. All rights reserved.
//

#ifndef compilation_def_comparison_expression_h
#define compilation_def_comparison_expression_h

/*
 comparison_expression
 : additive_expression {printf("comparison_expression\n");}
 | additive_expression '<' additive_expression {printf("comparison_expression\n");}
 | additive_expression '>' additive_expression {printf("comparison_expression\n");}
 | additive_expression LE_OP additive_expression {printf("comparison_expression\n");}
 | additive_expression GE_OP additive_expression {printf("comparison_expression\n");}
 | additive_expression EQ_OP additive_expression {printf("comparison_expression\n");}
 | additive_expression NE_OP additive_expression {printf("comparison_expression\n");}
 ; 
 */

struct def_comparison_expression{
	void *parent;
	int type;
	struct def_additive_expression * additive_expression;
	struct def_additive_expression * additive_expression_2;
};

struct def_comparison_expression * comparison_expression_create(void * parent){
	struct def_comparison_expression * s = malloc(sizeof(*s));
	s->type = 0;
	s->parent = parent;
	return s;
}

void comparison_expression_print(struct def_comparison_expression * c){
	switch(c->type){
		case 1:
			additive_expression_print(c->additive_expression);
			break;
		case 2:
			additive_expression_print(c->additive_expression);
			printf("<");
			additive_expression_print(c->additive_expression_2);
			break;
		case 3:
			additive_expression_print(c->additive_expression);
			printf(">");
			additive_expression_print(c->additive_expression_2);
			break;
		case 4:
			additive_expression_print(c->additive_expression);
			printf("<=");
			additive_expression_print(c->additive_expression_2);
			break;
		case 5:
			additive_expression_print(c->additive_expression);
			printf(">=");
			additive_expression_print(c->additive_expression_2);
			break;
		case 6:
			additive_expression_print(c->additive_expression);
			printf("==");
			additive_expression_print(c->additive_expression_2);
			break;
		case 7:
			additive_expression_print(c->additive_expression);
			printf("!=");
			additive_expression_print(c->additive_expression_2);
			break;
	}
}
#endif
